package com.GLM.Viewer.Main;

import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Serializable;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.provider.MediaStore;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;

import com.GLM.Constants.Constant;
import com.GLM.Entity.UnReadMeetMsg;
import com.GLM.Entity.UnReadRIVMsg;
import com.GLM.Entity.UnReadRingMsg;
import com.GLM.Entity.UnReadSms;
import com.GLM.Entity.UserInfoDetailEntity;
import com.GLM.Entity.UserInfoEntity;
import com.GLM.Tools.DB.DAO.UserInfoDAO;
import com.GLM.Tools.Utils.ViewsUtil;
import com.GLM.Tools.Utils.Image.AsynImageLoader;
import com.GLM.Tools.Utils.Image.AvatarUtil;
import com.GLM.Tools.Utils.JSON.JSONResponse;
import com.GLM.Tools.Utils.JSON.JSONResponse.Status;
import com.GLM.Tools.Utils.JSON.JSONUtil;
import com.GLM.Viewer.R;
import com.GLM.Viewer.Circle.CircleMainActivity;
import com.GLM.Viewer.Friends.FriendsMainActivity;
import com.GLM.Viewer.Message.MessageMainActivity;
import com.GLM.Viewer.MyNews.MyNewsActivity;
import com.GLM.Viewer.Party.PartyDetailActivity;
import com.GLM.Viewer.Party.PartyMainActivity;
import com.GLM.Viewer.Users.UserSettingActivity;
import com.google.gson.Gson;

public class MainActivity extends Activity {
	private final static int MSG_UNREAD_LOADING = 111;
	private final static int MSG_UNREAD_LOADED = 222;
 
	private final static int UPLOADING_INFO = 1;
	private final static int UPLOADED_INFO = 2;
	
	private Button avatarBtn;
	View mInputFieldMoreLines;
	EditText mInputFieldMoreLinesEditText;	
	Animation mAnimIn;
	Animation mAnimOut;
	InputMethodManager imm;
	
	private LinearLayout linLayout;
	private TextView tip4;
	private TextView tip3;
	private TextView tip2;
	private TextView tip1;
    Animation mViewAnimIn;
	private Handler mHandler;
	Button btnImageView;
	private Bitmap mDrawableAvater;
	private String takePhotoPath;
	private String fromalbumPath;
	private boolean takePhoto = false;
	private boolean fromAlbum = false;
	public String photoName;
	private int status;
	
	public String comContent;
	private UserInfoEntity mUserInfoEntity;
	private ArrayList<UnReadRIVMsg> mUnReadRIVMsgList = new ArrayList<UnReadRIVMsg>();
	private ArrayList<UnReadSms> mUnReadSmsList = new ArrayList<UnReadSms>();
	private ArrayList<UnReadMeetMsg> mUnReadMeetMsgList = new ArrayList<UnReadMeetMsg>();
	private ArrayList<UnReadRingMsg> mUnReadRingMsgList = new ArrayList<UnReadRingMsg>();
	ProgressDialog pd;
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.view_main);
		imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
		mUserInfoEntity = UserInfoDAO.getUserInfo(this);
		TextView nickNameView = (TextView) findViewById(R.id.mainview_nickname);
		
		linLayout = (LinearLayout)findViewById(R.id.mainview_undo_msg);
		avatarBtn = (Button)findViewById(R.id.user_avater_button);
		
		
		tip4 = (TextView) findViewById(R.id.mainview_tip4);
		tip3 = (TextView) findViewById(R.id.mainview_tip3);
		tip2 = (TextView) findViewById(R.id.mainview_tip2);
		tip1 = (TextView) findViewById(R.id.mainview_tip1);
		mViewAnimIn = AnimationUtils.loadAnimation(MainActivity.this, R.anim.anim_down_in);
		View view = (View)findViewById(R.id.viewmain_layout);
		
		view.setAnimation(mViewAnimIn);
		nickNameView.setText(mUserInfoEntity.getNickName()+"");
		initInputFields();
		initAnimation();
		initRegisterInputFieldButton();
		
		final SharedPreferences sp = getSharedPreferences(Constant.SHAREDNAME, MODE_PRIVATE);
		boolean isshow = sp.getBoolean(Constant.MAINACTIVITY, true);
		final ImageView tipView = (ImageView)findViewById(R.id.tipView);
		if(!isshow){
			tipView.setVisibility(View.VISIBLE);
			tipView.setOnTouchListener(new OnTouchListener() {
				
				public boolean onTouch(View v, MotionEvent event) {
					// TODO Auto-generated method stub
					tipView.setVisibility(View.INVISIBLE);
					tipView.setImageBitmap(null);
					Editor editor = sp.edit();
					editor.putBoolean(Constant.MAINACTIVITY, true);
					editor.commit();
					System.gc();
					return true;
				}
			});
		}
		mHandler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				Thread thread;
				switch (msg.what) {
				case MSG_UNREAD_LOADING:
					thread = new Thread(new Runnable() {
						public void run() {
							initUnreadAllMessage(mUserInfoEntity.getUserId());
							
							mHandler.sendEmptyMessage(MSG_UNREAD_LOADED);
						}
					});
					thread.start();
					break;

				case MSG_UNREAD_LOADED:
					if (mUnReadSmsList.size() > 0) {
						tip1.setText(mUnReadSmsList.size() + tip1.getText().toString());
						tip1.setVisibility(View.VISIBLE);
						linLayout.setVisibility(View.VISIBLE);
					}
					if (mUnReadMeetMsgList.size() > 0) {
						tip2.setText(mUnReadMeetMsgList.size() + tip2.getText().toString());
						tip2.setVisibility(View.VISIBLE);
						linLayout.setVisibility(View.VISIBLE);
					}
					if (mUnReadRingMsgList.size() > 0) {
						tip3.setText(mUnReadRingMsgList.size() + tip3.getText().toString());
						tip3.setVisibility(View.VISIBLE);
						linLayout.setVisibility(View.VISIBLE);
					}
					if (mUnReadRIVMsgList.size()>0){
						tip4.setText(mUnReadRIVMsgList.size() + tip4.getText().toString());
						tip4.setVisibility(View.VISIBLE);
						linLayout.setVisibility(View.VISIBLE);
					}
					initUserAvater();
					break;
				case UPLOADING_INFO:
					pd = ProgressDialog.show(MainActivity.this, "", getString(R.string.dataupdate), true, true);
					thread = new Thread(new Runnable() {
						
						public void run() {
							// TODO Auto-generated method stub
							Looper.prepare();
							try {
								if(fromAlbum || takePhoto)
									uploadFile();
							} catch (ClientProtocolException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							} catch (IOException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}
							status = initComment(comContent);
							mHandler.sendEmptyMessage(UPLOADED_INFO);
							Looper.loop();
						}
					});
					thread.start();
					break;
				case UPLOADED_INFO:
					if(status == 2){
						
						Toast.makeText(MainActivity.this, getString(R.string.send_success), Toast.LENGTH_LONG).show();
					}else {
						Toast.makeText(MainActivity.this, getString(R.string.send_fail), Toast.LENGTH_LONG).show();
					}
					if(pd != null && pd.isShowing()){
						pd.cancel();
					}
					break;
				}
			}
		};
		
		mHandler.sendEmptyMessage(MSG_UNREAD_LOADING);
	}

	private void initInputFields() {
		mInputFieldMoreLines = findViewById(R.id.inputfield_moreline);
		mInputFieldMoreLines.setVisibility(View.GONE);
		mInputFieldMoreLinesEditText = (EditText) findViewById(R.id.inputfieldmoreline_edittext);
		
	}

	private void initAnimation() {
		mAnimIn = AnimationUtils.loadAnimation(this, R.anim.anim_register_in);
		mAnimOut = AnimationUtils.loadAnimation(this, R.anim.anim_register_out);
	}
	
	private void showMoreLinesInputField() {
		mInputFieldMoreLines.startAnimation(mAnimIn);
		mInputFieldMoreLines.setVisibility(View.VISIBLE);
		mInputFieldMoreLinesEditText.requestFocus();
		imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
	}
	private void initRegisterInputFieldButton() {
		// more line
		btnImageView = (Button)findViewById(R.id.comment_image_button);
		btnImageView.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				// TODO Auto-generated method stub
				AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
				builder.setPositiveButton(getString(R.string.avater_album), new DialogInterface.OnClickListener() {
					
					public void onClick(DialogInterface dialog, int which) {
						// TODO Auto-generated method stub
						dialog.dismiss();
						Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
						intent.addCategory(Intent.CATEGORY_OPENABLE);
						intent.setType("image/*");
						startActivityForResult(Intent.createChooser(intent, "Selete Picture"), Constant.ACTIVITY_REQUESTCODE_ALBUM);
					}
				});
				builder.setNeutralButton(getString(R.string.avater_takepicture), new DialogInterface.OnClickListener() {
					
					public void onClick(DialogInterface dialog, int which) {
						// TODO Auto-generated method stub
						dialog.dismiss();
						Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
						startActivityForResult(intent, Constant.ACTIVITY_REQUESTCODE_TAKEPICTURE);
					}
				});
				builder.setNegativeButton(getString(R.string.cancel), null);
				builder.setTitle(getString(R.string.newparty_tips_dialog));
				builder.show();
			}
		});
		Button inputMoreLineCancelButton = (Button) findViewById(R.id.inputfieldmoreline_cancelbutton);
		inputMoreLineCancelButton.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				hideMoreLinesInputField();
				
			}
		});

		Button inputMoreLineOkButton = (Button) findViewById(R.id.inputfieldmoreline_okbutton);
		inputMoreLineOkButton.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				comContent = mInputFieldMoreLinesEditText.getText().toString().trim();
				if(!comContent.equals("")){
					hideMoreLinesInputField();
					imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
					mHandler.sendEmptyMessage(UPLOADING_INFO);
					
					
				}
			}
		});
		
	}
	
	public int initComment(String mCommentString){
		JSONObject jsonData = new JSONObject();
		JSONResponse jsonResponse = null;
		int status = -1;
		try {
			int user_id = UserInfoDAO.getUserInfo(MainActivity.this).getUserId();
			jsonData.put(Constant.PARAM_USERID_ONE, user_id);
			if(takePhoto || fromAlbum){
				jsonData.put("picture", photoName);
			}
			jsonData.put("content", mCommentString);
			jsonData.put("spreadLevel", 0);
			jsonData.put("issue", 2);
			jsonData.put("parent_id", 0);
			jsonData.put("mc_id", 0);
			jsonData.put("ring_id", 0);
			jsonResponse = JSONUtil.postRequest(Constant.REQ_WAY_COMMENTPARTY , jsonData);
			if (jsonResponse.getStatus() != Status.ERR) {
				JSONObject data = jsonResponse.getData();
				status = data.getInt(Constant.RESP_STATUS);
				
			}
		} catch (Exception e) {
			// TODO: handle exception
			
		}
		return status;
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub
		if(resultCode == RESULT_OK){
			switch (requestCode) {
			case Constant.ACTIVITY_REQUESTCODE_ALBUM:
				String str = checkImagePath(data);
				if(str != null){
					takePhoto = false;
					fromAlbum = true;
					String end = str.substring(str.lastIndexOf("."));
					int endindex = str.lastIndexOf("/")+1;
					String fpath = str.substring(0, endindex);
					File file = new File(str);
					String filename = formatDatetime(new Date(), "yyyyMMddHHmmsssss")+end;
					File newFile = new File(fpath+filename);
					file.renameTo(newFile);
					
					fromalbumPath = newFile.getAbsolutePath();
					Log.d("fromalbum", fromalbumPath);
					photoName = filename;
					Log.d("photoName", photoName);
					Log.d("ImageChoosepath", str);
				}
				startPhotoZoom(data.getData());
				break;
			case Constant.ACTIVITY_REQUESTCODE_TAKEPICTURE:
				String status = Environment.getExternalStorageState();
				if(!status.equals(Environment.MEDIA_MOUNTED)){
					Toast.makeText(MainActivity.this, getString(R.string.sdcard_notin), Toast.LENGTH_LONG).show();
					return ;
				}
				Uri uri = data.getData();
				if(uri != null){
					mDrawableAvater = BitmapFactory.decodeFile(uri.getPath());
				}
				if(mDrawableAvater == null){
					Bundle bundle = data.getExtras();
					if(bundle != null){
						mDrawableAvater =  (Bitmap)bundle.get("data");
					}else{
						Toast.makeText(MainActivity.this, "获取照片失败", Toast.LENGTH_LONG).show();
						return;
					}
				}
				
				FileOutputStream outputStream = null;
				photoName = formatDatetime(new Date(), "yyyyMMddHHmmsssss")+".jpg";
				String dirstr = Environment.getExternalStorageDirectory().toString() +"/glemei";
				File dir = new File(dirstr);
				
				if (!dir.exists()) {
					dir.mkdir(); 
				}
				File file = new File(dirstr, photoName);
				try {
					file.createNewFile();
				} catch (IOException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
				takePhotoPath = file.getAbsolutePath();
				Log.d("takePhotoPath", takePhotoPath);
				try {
					outputStream = new FileOutputStream(takePhotoPath);
					mDrawableAvater.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
					
				} catch (Exception e) {
					// TODO: handle exception
				}
				Log.d("beginWriteImage", "begin");
				WriteImage();
				takePhoto = true;
				fromAlbum = false;
				btnImageView.setBackgroundDrawable(AvatarUtil.Bitmap2Drawable(mDrawableAvater));
				
				break;
			case Constant.ACTIVITY_REQUESTCODE_NEWAVATER:
				Drawable newAvater = getNewAvater(data);
				
				if (newAvater != null) {
					mDrawableAvater = ((BitmapDrawable) newAvater).getBitmap();
					btnImageView.setCompoundDrawables(newAvater, null, null, null);
				}
				break;	
			case Constant.PARTY_HISTORY_REBUILDPARTY:
				Bundle bd = data.getExtras();
				if(bd != null){
					int qstatus = bd.getInt("status");
					if(qstatus == 1){
						Toast.makeText(MainActivity.this, getString(R.string.party_rebuild_success), Toast.LENGTH_LONG).show();
					}
				}
				break;
			default:
				break;
			}
		}
		
	}
	
	 public void WriteImage() {  
	        try {  
	            FileInputStream fis = new FileInputStream(takePhotoPath);  
	            ByteArrayOutputStream baos = new ByteArrayOutputStream();  
	            byte[] buffer = new byte[8192];  
	            int count = 0;  
	            while ((count = fis.read(buffer)) >= 0) {  
	                baos.write(buffer, 0, count);  
	  
	            }  
	            fis.close(); 
	            
	        } catch (FileNotFoundException e) {  
	            e.printStackTrace();  
	        } catch (IOException e) {  
	            e.printStackTrace();  
	        }  
	 }  
	
	 
	public void uploadFile() throws ClientProtocolException, IOException{
		File file = null;
		
		if(takePhoto){
			file = new File(takePhotoPath);
		}
		if(fromAlbum){
			file = new File(fromalbumPath);
		}
		
		 try {
//			 	URL url = new URL("http://192.168.3.100:8088/phpProject/push/android_upload.php?filename="+photoName);
	            URL url = new URL(Constant.URL_PARTY_COMMENT +"?filename="+photoName);
	            HttpURLConnection httpUrlConnection = (HttpURLConnection) url.openConnection();
	            httpUrlConnection.setDoOutput(true);
	            httpUrlConnection.setDoInput(true);
	            httpUrlConnection.setUseCaches(false);
	            httpUrlConnection.setRequestMethod("POST");
	            OutputStream os = httpUrlConnection.getOutputStream();
	            Thread.sleep(100);
	            BufferedInputStream fis = new BufferedInputStream(new FileInputStream(file));

	            int bufSize = 0;
	            byte[] buffer = new byte[1024];
	            while ((bufSize = fis.read(buffer)) != -1) {
	                os.write(buffer, 0, bufSize);
	            }
	            fis.close();

	            String responMsg = httpUrlConnection.getResponseMessage();
	            
	        } catch (Exception e) {
	           e.printStackTrace();
	        }
	
	}
	
	private String checkImagePath(Intent data){
		Cursor cursor = null;
		String path = null;
		try {
			Uri originalUri = data.getData();
			path = originalUri.toString();
			String[] proj = { MediaStore.Images.Media.DATA };
			cursor = managedQuery(originalUri, proj, null, null, null);
			if (cursor != null) {
				int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
				cursor.moveToFirst();
				// 最后根据索引值获取图片路径
				path = cursor.getString(column_index);
				Log.d("checkImagePath_path", path);
			}
		}
	    catch (Exception e) {
			Log.e("checkImage", e.getMessage());
		} finally {
			if (cursor != null && !cursor.isClosed()) 
				cursor.close();
		}
		
		return path;		
	}
	
	public static String formatDatetime(Date date, String format) {  
        DateFormat df = new SimpleDateFormat(format);  
        return df.format(date);  
    }  
	
	private Drawable getNewAvater(Intent data) {
		if (null != data) {
			Bundle bundle = data.getExtras();
			if (null != bundle) {
				Bitmap photo = bundle.getParcelable("data");
				
				Drawable drawable = new BitmapDrawable(photo);
				drawable.setBounds(0, 0, 100, 100);
				return drawable;
			}
		}
		return null;

	}
	
	public void startPhotoZoom(Uri uri) {
		Intent intent = new Intent("com.android.camera.action.CROP");
		intent.setDataAndType(uri, "image/*");
		intent.putExtra("crop", "true");
		intent.putExtra("aspectX", 1);
		intent.putExtra("aspectY", 1);
		intent.putExtra("outputX", 300);
		intent.putExtra("outputY", 300);
		intent.putExtra("return-data", true);
		startActivityForResult(intent, Constant.ACTIVITY_REQUESTCODE_NEWAVATER);
	}
	
	private void hideMoreLinesInputField() {
		mInputFieldMoreLinesEditText.setText("");
		mInputFieldMoreLinesEditText.clearFocus();
		mInputFieldMoreLines.startAnimation(mAnimOut);
		mInputFieldMoreLines.setVisibility(View.GONE);
		if(imm.isActive())
			imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
	}
	
	private void initUnreadAllMessage(int userId) {
		initUnreadListViews(userId, Constant.RESP_UNREAD_SMS,UnReadSms.class, mUnReadSmsList);
		initUnreadListViews(userId, Constant.RESP_UNREAD_RINGIV,UnReadRIVMsg.class, mUnReadRIVMsgList);
		initUnreadListViews(userId, Constant.RESP_UNREAD_MEET,UnReadMeetMsg.class, mUnReadMeetMsgList);
		initUnreadListViews(userId, Constant.RESP_UNREAD_RING,UnReadRingMsg.class, mUnReadRingMsgList);
	}
	
	public void initUserAvater(){
		Bitmap rawbitmap = UserInfoDAO.getUserInfo(MainActivity.this).getUserAvatar();
		
		if(rawbitmap != null){
			Bitmap bitmap = AvatarUtil.zoomBitmap(rawbitmap, 40, 40);
			Bitmap mbitmap = AvatarUtil.getRoundedCornerBitmap(bitmap, 16);
			avatarBtn.setBackgroundDrawable(AvatarUtil.Bitmap2Drawable(mbitmap));
			Log.d("rawbitmap", "rawbitmap is not null");
		}
		else {
			AsynImageLoader imageLoader = new AsynImageLoader();
			String url = UserInfoDAO.getUserInfo(MainActivity.this).getAvatarUrl();
			Log.d("AvatarUrl", url+"");
			Bitmap bmp = imageLoader.getAsyncBitmap(Constant.URL_USER_MIDDLE+mUserInfoEntity.getAvatarUrl());
			if(bmp != null){
				rawbitmap = AvatarUtil.zoomBitmap(bmp, 35, 35);
			}
			else{
				Drawable drawable = getResources().getDrawable(R.drawable.glm_avarat_testpic);
				Bitmap temp = AvatarUtil.drawableToBitmap(drawable);
				rawbitmap = AvatarUtil.zoomBitmap(temp, 35, 35);
			}
			Bitmap bitmap = AvatarUtil.getRoundedCornerBitmap(rawbitmap, 16);
			UserInfoDAO.setUserAvatar(bitmap);
			avatarBtn.setBackgroundDrawable(AvatarUtil.Bitmap2Drawable(bitmap));
		}
	}

	@SuppressWarnings("unchecked")
	public void initUnreadListViews(int userId,String jsonDataStr,Class entityClass,List unReadList){
		JSONObject request = new JSONObject();
		try {
			request.put(Constant.PARAM_USERID, userId);
			JSONResponse jsonResponse = JSONUtil.postRequest(65, request);
			if (jsonResponse.getStatus() != Status.ERR) {
				JSONObject data = jsonResponse.getData();
				int status = -1;
				status = data.getInt(Constant.RESP_STATUS);
				if (status == Constant.RESP_STATUS_SUCCESS) {
					JSONObject jsonObject = data.getJSONObject("allData");
					Gson gson = new Gson();
					JSONArray jsonArray =  jsonObject.getJSONArray(jsonDataStr);
					for(int i=0;i<jsonArray.length(); i++){
						Log.d("jsonData>>>", jsonArray.toString());
						Object msgEntity = gson.fromJson(jsonArray.getJSONObject(i).toString(), entityClass);
						if (entityClass.isInstance(msgEntity)) {
							unReadList.add(msgEntity);
						}
					}
					
				}
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}
	
	

	public void onUseravater_OnClick(View v){
		Intent intent = new Intent(MainActivity.this,UserSettingActivity.class);
		startActivity(intent);
	}
	
	public void onClick_ImageButtonMyNews(View v) {
		Intent intent = new Intent(this, MyNewsActivity.class);
		intent.putExtra(Constant.UNREAD_RINGIV_MSG, (Serializable)mUnReadRIVMsgList);
		intent.putExtra(Constant.UNREAD_SMS, (Serializable) mUnReadSmsList);
		intent.putExtra(Constant.UNREAD_MEET_MSG, (Serializable) mUnReadMeetMsgList);
		intent.putExtra(Constant.UNREAD_RING_MSG, (Serializable) mUnReadRingMsgList);
		startActivity(intent);
	}

	public void onClick_ImageButtonCircle(View v) {
		Intent intent = new Intent(this, CircleMainActivity.class);
		startActivity(intent);
	}

	public void onClick_ImageButtonMessage(View v) {
		Intent intent = new Intent(this, MessageMainActivity.class);
		startActivity(intent);
	}

	public void onClick_ImageButtonFriends(View v) {
		Intent intent = new Intent(this, FriendsMainActivity.class);
		startActivity(intent);
	}

	public void onClick_ImageButtonParty(View v) {
		Intent intent = new Intent(this, PartyMainActivity.class);
		startActivity(intent);
	}

	public void onClick_newissue(View v){
		showMoreLinesInputField();
	}
	
}
